export function useUpload() {
  // 判断是否是字母
  function isLetter(str: string): boolean {
    return /^[A-Z]+$/i.test(str);
  }
  // 判断表头字段
  function areArraysEqualIgnoreOrder(arr1: any[], arr2: any[]): boolean {
    const sortedArr1 = [...arr1].sort();
    const sortedArr2 = [...arr2].sort();
    if (sortedArr1.length !== sortedArr2.length) {
      return false;
    }
    for (let i = 0; i < sortedArr1.length; i++) {
      if (sortedArr1[i] !== sortedArr2[i]) {
        return false;
      }
    }
    return true;
  }
  // 检查文件扩展名是否为Excel
  function checkIfExcel(fileName: string): boolean {
    const excelExtensions = ['xls', 'xlsx'];
    const fileExtension = fileName.toLowerCase().split('.').pop() || '';
    return excelExtensions.includes(fileExtension);
  }
  return {
    isLetter,
    areArraysEqualIgnoreOrder,
    checkIfExcel,
  };
}
